/**
 * @Description： TeacherGradeService接口的实现类
 * @author： 20155872 游宇
 * @createTime: 2018-05-17 8:18
 **/

package com.campus_information_portal.service.impl;

import com.campus_information_portal.dao.TeacherDao;
import com.campus_information_portal.dao.TeacherGradeDao;
import com.campus_information_portal.entity.TeacherGrade;
import com.campus_information_portal.service.TeacherGradeService;
import com.campus_information_portal.util.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @className: TeacherGradeImpl
 * @Description: TeacherGradeService接口的实现类
 * @author: 20155872 游宇
 * @createTime: 2018-05-17 8:18
 **/
@Service
public class TeacherGradeImpl implements TeacherGradeService {
@Autowired
    private TeacherGradeDao teacherGradeDao;

    @Override
    public Msg addTeacherGrade(TeacherGrade teacherGrade) {
        if (teacherGradeDao.addTeacherGrade(teacherGrade)){
            return Msg.addData(1,"已成功添加一条记录到teacherGrade表");
        }
        return Msg.fail();
    }

    @Override
    public Msg getTeacherGrade(int teInfoId, int termId) {
        TeacherGrade teacherGrade=teacherGradeDao.getTeacherGrade(teInfoId,termId);
        if (teacherGrade!=null){
            return Msg.addData(1,"已成功获取到一条教师得分记录",teacherGrade);
        }
        return Msg.fail();
    }

    @Override
    public Msg getAllTeacherGradeBytermId(int termId) {
        List<TeacherGrade> teacherGradeList=teacherGradeDao.getAllTeacherGradeBytermId(termId);
        if (teacherGradeList.size()!=0){
            return Msg.addData(1,"成功获取到某个学期所有老师的得分记录",teacherGradeList);
        }
        return Msg.fail();
    }
}
